package com.iqik.filter.utils;

import org.apache.dubbo.common.utils.Holder;

import javax.servlet.ServletRequest;

public class RequestHolder {

    private static ThreadLocal<ServletRequest> REQUEST_THREAD_LOCAL = new ThreadLocal<>();

    private final Holder<Object> cacheAdaptiveInstance = new Holder<>();

    public static void setting(ServletRequest request) {
        if (REQUEST_THREAD_LOCAL.get() == null) {
            REQUEST_THREAD_LOCAL.set(request);
        }
    }

    public static void remove() {
        REQUEST_THREAD_LOCAL.remove();
    }

    public static ServletRequest request() {
        return REQUEST_THREAD_LOCAL.get();
    }

}
